<?php

class Group extends Eloquent {
	/**
	 * The database table used by the model.
	 *
	 * @var string
	 */
	protected $table = 'users_group';

	/**
	 * Fetches the user that is the admin of the group 
	 *
	 * @return User 
	 */
	public function admin()
    {
        return $this->hasOne('User','id','admin_userId'); 
    }

    /**
	 * Fetches all the users that are members of this group 
	 *
	 * @return User array
	 */
	public function users()
    {
        return $this->belongsToMany('User', 'group_users', 'groupId', 'userId');
    }
}
